import { merge, ajax, fixPercent } from '../../helper/helper'
import { indexsData, userListMockData, mockOrderData, visitHistoryData, orderList } from '../static/index'
import _ from 'underscore'
import moment from 'moment'


// import { subscribeDateRange } from '../static/index'
import { postType, dateRange } from '../../static/index'
import {doAjaxPost} from "../../common/fetch-ajax";


/**
 * 钉店信息
 */
const renderData = function (dispatch, params) {
    //var type = params.type;

    ajax({
        type: 'GET',
        url: `/admin/api/dingstore`,
        data: params,
        success: (data) => {
            try { data = JSON.parse(data) } catch (err) { };
            if (data && data.success) {
                dispatch({
                    type: 'set-dingstore-form-list',
                    val: data.result
                })
            } else {
            }
        },
        error: () => {
            dispatch({

            })
        }
    })

}

const updateEntity = function(data, callback){
    doAjaxPost({
        url: 'https://dingdian-ppe.parllay.cn/wxserver/store/updateStore',
        data: {
            data
        },
        success: (result) => {
            let param = JSON.parse(result);
            callback(param);
        },
        error: (error) => {
            throwError("数据加载失败");
        }
    })
}


export const actions = {
    renderData: renderData,
    updateEntity: updateEntity
}